<template>
  <div>
    <el-container>
      <!-- width的宽度跟collapse一样动态控制 -->
      <el-header>
        <div
          :title="isCollapse ? '点击展开' : '点击收起'"
          class="box_bgd"
          @click="isC"
        >
          <!-- 点击展开收起导航和切换对应图标 -->
          <i :class="!isCollapse ? 'el-icon-s-fold' : 'el-icon-s-unfold'"></i>
        </div>
        <div class="qiehuan">
          <label class="ui-switch">
            <input type="checkbox" @click="qiehuan" id="qiehuan" />
            <div class="slider">
              <div class="circle"></div>
            </div>
          </label>
        </div>
        <!-- <div
          style="
            width: 200px;
            height: 200px;
            background-color: white;
            position: absolute;
            right: 10vw;
            top: 5px;
          "
          id="beijing"
        >
          背景颜色
        </div> -->
      </el-header>

      <el-container>
        <el-aside width="collapse">
          <el-menu
            :default-active="$route.path"
            router
            :collapse="isCollapse"
            class="el-menu-vertical"
            background-color="#393e42"
            text-color="#fff"
            active-text-color="rgb(64, 158, 255)"
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span class="el-submenuone">导航一</span>
              </template>
              <el-submenu index="fourziyuangongji">
                <template slot="title">
                  <span class="el-submenuone1">课程资源</span>
                </template>

                <el-menu-item-group>
                  <el-menu-item index="two1">红色资源</el-menu-item>
                  <el-menu-item index="two2">红色影音</el-menu-item>
                  <el-menu-item index="two3">教学案例</el-menu-item>
                  <el-menu-item index="two4">专题教室</el-menu-item>
                  <el-menu-item index="two5">虚拟仿真</el-menu-item>
                </el-menu-item-group>
              </el-submenu>
              <el-menu-item-group>
                <el-menu-item index="train">选项1</el-menu-item>
                <el-menu-item index="/onesecondone">选项2</el-menu-item>
                <el-menu-item index="/onesecond">选项3</el-menu-item>
                <el-menu-item index="/fath">选项4</el-menu-item>

                <!-- <el-submenu index="1-4">
                  <template slot="title">选项4</template>
                  <el-menu-item index="/onefirst" class="bottom"
                    >选项1</el-menu-item
                  >
                </el-submenu>

                <el-submenu index="1-5">
                  <template slot="title">选项5</template>
                  <el-menu-item index="newtry" class="bottom"
                    >选项1</el-menu-item
                  >
                </el-submenu>

                <el-submenu index="1-6">
                  <template slot="title">选项6</template>
                  <el-menu-item index="cssceshi" class="bottom"
                    >选项1</el-menu-item
                  >
                </el-submenu> -->
              </el-menu-item-group>
            </el-submenu>
            <el-menu-item index="two1">
              <i class="el-icon-menu"></i>
              <span slot="title">导航二</span>
            </el-menu-item>
            <el-menu-item index="3">
              <i class="el-icon-document"></i>
              <span slot="title">导航三</span>
            </el-menu-item>
            <el-menu-item index="newcss">
              <i class="el-icon-setting"></i>
              <span slot="title">柱状图</span>
            </el-menu-item>
            <el-menu-item index="swiper">
              <i class="el-icon-setting"></i>
              <span slot="title">轮播图</span>
            </el-menu-item>
            <el-menu-item index="qiehuan">
              <i class="el-icon-setting"></i>
              <span slot="title">白天黑</span>
            </el-menu-item>
            <el-menu-item index="newcss1">
              <i class="el-icon-setting"></i>
              <span slot="title">滚动条</span>
            </el-menu-item>
            <el-menu-item index="qianzidaochu">
              <i class="el-icon-setting"></i>
              <span slot="title">签字导</span>
            </el-menu-item>
            <el-menu-item index="jieping">
              <i class="el-icon-setting"></i>
              <span slot="title">截屏大</span>
            </el-menu-item>
            <el-menu-item index="tupianfangda">
              <i class="el-icon-setting"></i>
              <span slot="title">图片放</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main class="el-main" id="el-main">
          <div class="mianbaoxie">
            <Bread :fromFather="dataPath"></Bread>
          </div>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import Bread from "@/components/Bread.vue"; // 引入面包屑组件

export default {
  props: {
    dataPath: "",
  },
  data() {
    return {
      isCollapse: false, //默认为展开
      beijing: true,
    };
  },
  components: {
    Bread,
  },
  methods: {
    // 动态控制展开与收起和切换对应图标
    isC() {
      this.isCollapse = !this.isCollapse;
    },
    qiehuan() {
      // let div = document.getElementById("beijing");
      let div = document.getElementById("el-main");
      // console.log(div.style.background);
      this.beijing = !this.beijing; //反转背景颜色 （不是按钮状态） （true或false） 默认为true。

      console.log(this.beijing);
      // div.style.backgroundColor="white"
      if (this.beijing == true) {
        div.style.backgroundColor = "#e9eef3";
      } else if (this.beijing == false) {
        div.style.backgroundColor = "#393e42";
      }
    },
  },
};
</script>

<style lang="scss" >
.el-header {
  background: #b3c0d1;
  color: #333;
  padding: 0 !important;
  height: 8vh !important;
  box-shadow: 5px 5px 5px #000, -5px -5px 5px #000 !important;
  position: relative;
  .qiehuan {
    position: absolute;
    right: 3vw;
    top: 28px;
  }
}

::v-deep {
  .el-breadcrumb__item {
    font-size: 18px;
  }
}

.el-aside {
  background: #393e42;
  color: #333;
  height: 92vh;
  text-align: center;
}

// 隐藏侧边栏滚动条
.el-menu {
  border: 0 !important;
}
.el-main {
  background-color: #e9eef3;
  border-left: 1px solid #ccc;
  color: #333;
  position: relative;
  .mianbaoxie {
    position: absolute;
    left: 25px !important;
    top: 10px;
  }
}
.el-menu-vertical:not(.el-menu--collapse) {
  width: 240px;
}
.el-container {
  position: relative;
  .mianbaoxie {
    position: absolute;
    left: 1px;
  }
}
.box_bgd {
  width: 60px;
  height: 60px;
  font-size: 18px;
  margin-top: 8px;
  margin-left: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  // background-color: #393e42;
}
.box_bgd i {
  font-size: 20px;
}
.box_bgd:hover {
  background: rgb(203, 215, 230);
}
// 隐藏小箭头
// ::v-deep.el-submenu.is-opened > .el-submenu__title .el-submenu__icon-arrow {
//   display: none;
// }
// ::v-deep.el-submenu > .el-submenu__title .el-submenu__icon-arrow {
//   display: none;
// }
// 以上代码在style标签内+ scoped 可以生效 但随之而来的是 el-menu-item-group__title上下间距失效
.el-submenu.is-opened>.el-submenu__title .el-submenu__icon-arrow{
	display: none; 
}
.el-submenu>.el-submenu__title .el-submenu__icon-arrow{
	display: none;
}
.el-submenuone1{
  margin-right: 5px;
}
/* 隐藏横向滚动条 */
.page-scroll {
  height: 100%;
}
.page-scroll .el-scrollbar__wrap {
  overflow-x: hidden;
}
.el-aside::-webkit-scrollbar {
  display: none;
}

// ::v-deep.el-menu-item-group__title {
//   padding: 0 !important;
//   z-index: 102;
// }
.el-menu-item-group__title {
  padding: 0 !important;
  z-index: 100;
}
// 样式切换按钮
.ui-switch {
  /* switch */
  --switch-bg: rgb(135, 150, 165);
  --switch-width: 48px;
  --switch-height: 20px;
  /* circle */
  --circle-diameter: 32px;
  --circle-bg: rgb(0, 56, 146);
  --circle-inset: calc((var(--circle-diameter) - var(--switch-height)) / 2);
}

.ui-switch input {
  display: none;
}

.slider {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: var(--switch-width);
  height: var(--switch-height);
  background: var(--switch-bg);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
}

.slider .circle {
  top: calc(var(--circle-inset) * -1);
  left: 0;
  width: var(--circle-diameter);
  height: var(--circle-diameter);
  position: absolute;
  background: var(--circle-bg);
  border-radius: inherit;
  background-image: url("");
  background-repeat: no-repeat;
  background-position: center center;
  -webkit-transition: left 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
    -webkit-transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
  -o-transition: left 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
    transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
  transition: left 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
    transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
    -webkit-transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2),
    0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
}

.slider .circle::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.75);
  border-radius: inherit;
  -webkit-transition: all 500ms;
  -o-transition: all 500ms;
  transition: all 500ms;
  opacity: 0;
}

/* actions */

.ui-switch input:checked + .slider .circle {
  left: calc(100% - var(--circle-diameter));
  background-image: url("");
  // background-image: url(@/assets/logo.png);
}

.ui-switch input:active + .slider .circle::before {
  -webkit-transition: 0s;
  -o-transition: 0s;
  transition: 0s;
  opacity: 1;
  width: 0;
  height: 0;
}

.beijingtu2 {
  width: 50px;
  height: 50px;
  background-image: url();
}
</style>
